#include <iostream>
#include <queue>
#include <vector>

using namespace std;

const int N = 5010, M = 5e5 + 10, MOD = 80112002;
vector<int> edges[N];
int in[N];
int n, m;
int f[N];

int main()
{
	cin >> n >> m;
	while(m--)
	{
		int x, y; cin >> x >> y;
		in[y]++;
		edges[x].push_back(y);
	}
	// init
	queue<int> q;
	for(int i = 1; i <= n; i++)
	{
		if(in[i] == 0) 
		{
			q.push(i);
			f[i] = 1;
		}
	}
	while(q.size())
	{
		int t = q.front(); q.pop();
		for(auto x : edges[t])
		{
			f[x] += f[t];
			f[x] %= MOD;
			in[x]--;
			if(in[x] == 0) q.push(x); 
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		if(edges[i].size() == 0) 
		{
			ans += f[i];
			ans %= MOD;;
		}
	}
	cout << ans << endl;
	return 0;
}
